﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using AssessmentTool.PresentationLogic;
using AssessmentTool.PresentationLogic.Controllers;

namespace AssessmentTool.Controls
{
    public partial class Login : UserControl
    {

        protected LoginController controller;
        public Login()
        {
            InitializeComponent();
            controller = new LoginController(this);
           
        }
        public void onLogin(EventArgs e)
        {
            txtUsername.Text = "";
            txtPassword.Password = "";
            this.Visibility = Visibility.Collapsed;
            
        }
        public void onLogout(EventArgs e)
        {
            this.Visibility = Visibility.Visible;
        }

        public virtual void Button_Click(object sender, RoutedEventArgs e)
        {
            this.IsEnabled=false;
            EventDispatcher.getInstance().dispatch("BUSY",null);
            controller.callLogin();
            this.IsEnabled = true;
        }

        public virtual void UserControl_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                Button_Click(null, null);
            }
        }
        
       
    }
}
